/**
 * Project Name:mms
 * File Name:MeetingController
 * Package Name:com.scb.dev.mms.controller
 * Date:2018/12/422:43
 * Copyright (c) 2018, Yuchuan.Dong All Rights Reserved.
 */
package com.scb.dev.mms.controller;

import com.scb.dev.mms.common.DataCommon;
import com.scb.dev.mms.common.ResponseResult;
import com.scb.dev.mms.common.ResultType;
import com.scb.dev.mms.common.StatusCode;
import com.scb.dev.mms.dto.BookMeetingDto;
import com.scb.dev.mms.dto.InsertMeetingDto;
import com.scb.dev.mms.service.IRemoteService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;

/**
 * ClassName: MeetingController <br/>
 * @Description: ${todo} ADD REASON(可选). <br/><br/>
 * @Date: 2018/12/4 22:43 <br/> 
 *
 * @author Yuchuan.Dong
 * @version V1.0
 * @since JDK 1.8
 */
@RestController
@RequestMapping("/sm/")
public class MeetingController {

    @Resource
    private IRemoteService iRemoteService;

    /**
     * select someOne book meeting list
     * @param session
     * @return
     */
    @RequestMapping(value = "meeting",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
    public ResponseResult queryCustomBookMeetingInfo(HttpSession session){
        String current_account = (String)session.getAttribute(DataCommon.CURRENT_ACCOUNT_ID);
        if(StringUtils.isBlank(current_account)){
            return new ResponseResult(false, ResultType.USER_NOT_LOGIN, StatusCode.FAULT_FLAG);
        }
        return iRemoteService.queryCustomBookMeetingInfo(current_account);
    }

    /**
     * select available meeting room time information
     * @param bookMeetingDto
     * @param session
     * @return
     */
    @RequestMapping(value = "meeting/meeting_room/time",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"})
    public ResponseResult queryAvailableMeetingRoomTime(@RequestBody BookMeetingDto bookMeetingDto, HttpSession session){
        String current_account = (String)session.getAttribute(DataCommon.CURRENT_ACCOUNT_ID);
        if(StringUtils.isBlank(current_account)){
            return new ResponseResult(false, ResultType.USER_NOT_LOGIN, StatusCode.FAULT_FLAG);
        }
        return iRemoteService.queryAvailableMeetingRoomTime(bookMeetingDto);
    }

    /**
     * add new meeting information
     * @param insertMeetingDto
     * @param session
     * @return
     */
    @RequestMapping(value = "meeting",method = RequestMethod.POST,produces = {"application/json;charset=UTF-8"})
    public ResponseResult insertMeetingInfo(@RequestBody InsertMeetingDto insertMeetingDto, HttpSession session){
        String current_account = (String)session.getAttribute(DataCommon.CURRENT_ACCOUNT_ID);
        if(StringUtils.isBlank(current_account)){
            return new ResponseResult(false, ResultType.USER_NOT_LOGIN, StatusCode.FAULT_FLAG);
        }
        return iRemoteService.insertMeetingInfo(insertMeetingDto,current_account);
    }

    @RequestMapping(value = "meeting/meeting_room",method = RequestMethod.GET,produces = {"application/json;charset=UTF-8"})
    public ResponseResult queryAllMeetingRoom(HttpSession session){
        String current_account = (String)session.getAttribute(DataCommon.CURRENT_ACCOUNT_ID);
        if(StringUtils.isBlank(current_account)){
            return new ResponseResult(false, ResultType.USER_NOT_LOGIN, StatusCode.FAULT_FLAG);
        }
        return iRemoteService.queryAllMeetingRoom();
    }


}
